package com.grendel.tubeyourmind.youtube.vo
{
	import org.osmf.events.DurationChangeEvent;

	public class Playlist
	{
		public var id:String;

		public var title:String;

		public var subtitle:String;
		
		public var logo:String;

		private var _videos:Array;

		public function get videos():Array
		{
			return _videos;
		}

		public function set videos(value:Array):void
		{
			_videos = value;
			updateDuration();
		}

		private var _videosCount:int

		public function get videosCount():int
		{
			return _videos.length;
		}

		private var _duration:int;

		public function get duration():int
		{
			return _duration;
		}



		public function Playlist(id:String, title:String, subtitle:String, logo:String, videos:Array=null)
		{
			this.id = id;
			this.title = title;
			this.subtitle = subtitle;
			this.logo = logo;
			
			if (videos)
			{
				this.videos = videos;
				updateDuration();
			}
		}



		public function addVideo(video:Video):void
		{
			this.videos.push(video);
		}

		public function updateDuration():void
		{
			for (var i:int = 0; i < videos.length; i++)
			{
				this._duration = videos[i].duration;
			}
		}
	}
}